package com.hanthink.system.domain.protocol.photoalbum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.List;


/**
 * 相册请求
 *
 * @author WangBin
 * @date 2025-08-20
 */
@Data
@ApiModel("相册请求")
public class PhotoAlbumAddRequest {

    @ApiModelProperty("用户id")
    private String userId;
    @ApiModelProperty("图片列表")
    private List<String> picList;
    @ApiModelProperty("视频列表")
    private List<String> videoList;

    @Size(max = 10, message = "图片数量不能超过10张")
    public List<String> getPicList() {
        return picList;
    }

    @Size(max = 5, message = "视频数量不能超过5个")
    public List<String> getVideoList() {
        return videoList;
    }

    /**
     * 自定义校验：照片和视频至少有一个不为空且长度大于0
     */
    @AssertTrue(message = "照片和视频不能同时为空")
    public boolean isValidContent() {
        boolean hasPhotos = picList != null && !picList.isEmpty();
        boolean hasVideos = videoList != null && !videoList.isEmpty();
        return hasPhotos || hasVideos;
    }

    /**
     * 业务方法：获取总媒体数量
     */
    public int getTotalMediaCount() {
        int photoCount = picList != null ? picList.size() : 0;
        int videoCount = videoList != null ? videoList.size() : 0;
        return photoCount + videoCount;
    }
}
